using System;
using System.Collections.Generic;
using System.Web.Profile;

namespace SpiderMaster.AspNet.TradingSystem
{
    /// <summary> Trading Center Profile Common. </summary>
    [Serializable]
    [ReganSchroder(4, 10, 1, 10, 2009)]
    public partial class TradingCenterProfileCommon : CommunitiesProfileCommon, ITradingCenterProfileCommon
    {
        /// <summary> Empty. </summary>
        public static readonly TradingCenterProfileCommon Empty;

        static TradingCenterProfileCommon() { Empty = new TradingCenterProfileCommon(); }

        /// <summary> Initializes a new instance of the <see cref="TradingCenterProfileCommon"/> class. </summary>
        internal TradingCenterProfileCommon()
            : base()
        { /* This is required to create a new Profile on Trading Center so do not modify! */ }

        /// <summary> Initializes a new instance of the <see cref="TradingCenterProfileCommon"/> class. </summary>
        /// <param name="Base">The base.</param>
        public TradingCenterProfileCommon(ProfileBase Base) : base(Base) { }

        /// <summary> Gets a value indicating whether this instance is administrator. </summary>
        /// <value>
        /// 	<c>true</c> if this instance is administrator; otherwise, <c>false</c>.
        /// </value>
        [ReganSchroder(5, 10, 2009)]
        public bool IsAdministrator { get { return IsInRole(PredefinedRole.GeneralAdministrator); } }

        /// <summary> Gets or sets the mail sent to. </summary>
        /// <value>The mail sent to.</value>
        public MailSentTo MailSentTo
        {
            get { return Enum<MailSentTo>.Parse(base.GetPropertyValue(ProfilePropertyKey.MailSentTo).ToString()); }
            set { base.SetPropertyValue(ProfilePropertyKey.MailSentTo, value); }
        }

        /// <summary> Gets or sets the master location id. </summary>
        /// <value>The master location id.</value>
        public int MasterLocationId
        {
            get { return int.Parse(base.GetPropertyValue(ProfilePropertyKey.MasterLocationId).ToString()); }
            set { base.SetPropertyValue(ProfilePropertyKey.MasterLocationId, value); }
        }

        /// <summary> Residential Details, All Must be defined other than FlatAppartmentNumber. </summary>
        /// <value></value>
        [SettingsAllowAnonymous(false)]
        public ProfileGroupResidentialDetails ResidentialDetails { get { return new ProfileGroupResidentialDetails(this.GetProfileGroup(ProfilePropertyKey.ResidentialDetails)); } }

        /// <summary> Secondary Details <b>Optional</b>. </summary>
        /// <value></value>
        [SettingsAllowAnonymous(false)]
        public ProfileGroupSecondaryDetails SecondaryDetails { get { return new ProfileGroupSecondaryDetails(this.GetProfileGroup(ProfilePropertyKey.SecondaryDetails)); } }

        /// <summary> Business Details <b>Optional</b>. </summary>
        /// <value></value>
        [SettingsAllowAnonymous(false)]
        public ProfileGroupBusinessDetails BusinessDetails { get { return new ProfileGroupBusinessDetails(this.GetProfileGroup(ProfilePropertyKey.BusinessDetails)); } }

        /// <summary> Provides Permanent Setting Options for Panels on this site. </summary>
        /// <value></value>
        public ProfileGroupActionPanels ActionPanels { get { return new ProfileGroupActionPanels(this.GetProfileGroup(ProfilePropertyKey.ActionPanels)); } }

        /// <summary> Gets the errors. </summary>
        /// <value>The errors.</value>
        public List<string> Errors { get { return this.GetErrors(); } }

        /// <summary> Gets a value indicating whether this instance has errors. </summary>
        /// <value>
        /// 	<c>true</c> if this instance has errors; otherwise, <c>false</c>.
        /// </value>
        public bool HasErrors { get { return (Errors.Count > 0); } }
    }
}